//Ext.onReady(fn)代表DOM加载完毕，所有js代码可用！
Ext.onReady(function () {
	
	// 从这里开始说明js可用了！
	alert("dom has get ready!");
	
	// 添加段落脚本
	//select("元素名")选出一个元素组合
	Ext.select("p").on("click", function (e) {
		var paragraph = Ext.get(e.target);
		paragraph.highlight();
		Ext.MessageBox.show({
			title:"Paragraph Clicked", 
			msg:paragraph.dom.innerHTML, 
			width:400, 
			buttons:Ext.MessageBox.OK, 
			animEl:paragraph
		});
	});
	
	// 添加按钮脚本
	//get("id名")选出对应id的元素
	Ext.get("login").on("click", function () {
		Ext.Msg.prompt("Name", "Please enter your name:", function (btn, text) {
			if (btn == "ok") {
				if (text.trim() !== "") {
					Ext.Msg.alert("Message", "welcome " + text);
				}
			}
		});
	});

	//添加Tips脚本
	Ext.get("quicktips").on("click", function () {
		Ext.QuickTips.init();
		var q = Ext.QuickTips.getQuickTip();

		// 设置这个QuickTips的参数
		q.maxWidth = 200;
		q.minWidth = 100;
		q.showDelay = 50;
		q.trackMouse = true;

		// 注册此Tips到一个名称空间中，以便调用
		q.register({
			target:"my-div",
			title:"My Tooltip",
			text:"This tooltip was added in code",
			width:100, dismissDelay:20
		});
	});
});

